package com.crs.controller.admin;

import com.crs.dto.AdminAcceptOrRejectDTO;
import com.crs.result.Result;
import com.crs.service.AdminService;
import com.crs.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/admin")
public class adminController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private UserService userService;

    @PostMapping("/acceptOrReject")
    public Result adminAcceptOrReject(@RequestBody AdminAcceptOrRejectDTO adminAcceptOrRejectDTO){
        log.info("管理员同意或拒绝申请",adminAcceptOrRejectDTO);
        adminService.acceptOrReject(adminAcceptOrRejectDTO);
        return Result.success();
    }

    @PostMapping("/releaseOrBan/{status}")
    public Result adminReleaseOrBan(@PathVariable Integer status,Long userId){
        log.info("管理员",userId);
        userService.releaseOrBan(status,userId);
        return Result.success();
    }
}
